/*
 * IUnit.cpp
 *
 *  Created on: 07.12.2011
 *      Author: Kirill Blinov
 *      Copyright: LGPL
 */

#include "IUnit.h"

IUnit::IUnit( GAME_OBJECT* VisualisationInfo ) : physicParams(NULL)
{
	visualisationInfo = VisualisationInfo;
}

IUnit::~IUnit()
{
	if ( physicParams != NULL )
	{
		delete physicParams;
	}

	delete visualisationInfo; //It should be always allocated
}

/*
 * Returns true on the first call only, so the name can be changed only set once.
 */
bool
IUnit::SetName( const std::string Name )
{
	bool Result = !name.empty();

	if ( Result )
	{
		name = Name;
	}

	return Result;
}

/*
 * Sets initial object parameters like a speed, velocity e.t.c.
 * Returns true on the first call only.
 */
bool
IUnit::SetPhysicParams( const UNIT_PHYSIC_PARAMS &PhysicParams )
{
	bool Result = ( NULL == physicParams );
	if ( Result )
	{
		physicParams = new UNIT_PHYSIC_PARAMS( PhysicParams );
	}

	return Result;
}

const std::string
IUnit::GetName() const
{
	return name;
}

UINT_EVENT
IUnit::PopEvent()
{
	UINT_EVENT Event = eventQueue.front();
	eventQueue.pop();
	return Event;
}

